﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ArrayListTest2
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList list1 = new ArrayList();
            list1.Add("aaa");
            list1.Add("bbb");
            list1.Add("ccc");
            list1.Add("asfdadsfa");
            list1.Add("asdfasdfsaf");

            //list1.Remove("bbb");
            list1.RemoveAt(0);

            Console.WriteLine(list1[0]);
            //Remove一个元素以后后面的元素会递补

            PrintList(list1);

            Console.WriteLine(list1.Contains("www"));//判断是否存在
            Console.WriteLine(list1.Contains("ccc"));

            list1.Clear();//清空

            Console.WriteLine(list1.Count);

            Console.ReadKey();
        }

        static void PrintList(ArrayList list)
        {
            foreach (object obj in list)
            {
                Console.WriteLine(obj);
            }
        }
    }
}
